package com.example.demo2.bean;

import java.util.Arrays;
import java.util.List;

/**
 * CD架
 */
public class Library {
    private final List<Cd> collection;

    public Library(Cd[] cdCollection) {
        this.collection = Arrays.asList(cdCollection);
    }

    public List<Cd> getCollection() {
        return collection;
    }

    /**
     * 张学友唱片集 包含了 2张CD 4首歌曲
     * @return
     */
    public static Library buildSampleLibrary() {
        Track cd1track1 = new Track("情已逝", 5 * 60 + 56);
        Track cd1track2 = new Track("在我心深处", 3 * 60 + 36);
        Cd cd1 = new Cd("一生跟你走作品集 I", new Track[] { cd1track1, cd1track2 });
        Track cd2track1 = new Track("思念", 4 * 60 + 22);
        Track cd2track2 = new Track("吻别", 4 * 60 + 8);
        Cd cd2 = new Cd("一生跟你走作品集 II", new Track[] { cd2track1, cd2track2 });
        return new Library(new Cd[] { cd1, cd2 });
    }

}
